//
//  AboutCell.m
//  Assistant
//
//  Created by Hunk on 12-3-8.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "AboutCell.h"
#import <QuartzCore/QuartzCore.h>

#define IMAGEVIEW_TAG (11)
#define TEXTLABEL_TAG (12)

#define SECTION_2_IMAGEVIEW_TAG (13)
#define SECTION_2_TEXTLABEL_TAG (14)

@implementation AboutCell
@synthesize indexPath = _indexPath;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) 
    {
        _identifier = reuseIdentifier;
        
        if([reuseIdentifier isEqualToString:REUSEIDENTIFIER_0])
        {
            self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            self.selectionStyle = UITableViewCellSelectionStyleBlue;
            
            // Icon
            UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 44.0, 44.0)];
            [imageView setBackgroundColor:[UIColor clearColor]];
            [imageView setTag:IMAGEVIEW_TAG];
            [self.contentView addSubview:imageView];
            [imageView release];
            
            // Name 
            UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 2, 240, 40)];
            [textLabel setBackgroundColor:[UIColor clearColor]];
            [textLabel setTag:TEXTLABEL_TAG];
            [self.contentView addSubview:textLabel];
            [textLabel release];
        }
        else if([reuseIdentifier isEqualToString:REUSEIDENTIFIER_1])
        {
            self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            self.selectionStyle = UITableViewCellSelectionStyleBlue;
            
            // Icon
            UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 1, 44.0, 44.0)];
            [imageView setBackgroundColor:[UIColor clearColor]];
            imageView.layer.cornerRadius = 6.0;
            imageView.layer.masksToBounds = YES;
            [imageView setTag:SECTION_2_IMAGEVIEW_TAG];
            [self.contentView addSubview:imageView];
            [imageView release];
            
            // Name 
            UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 3, 240, 40)];
            [textLabel setBackgroundColor:[UIColor clearColor]];
            [textLabel setTag:SECTION_2_TEXTLABEL_TAG];
            [self.contentView addSubview:textLabel];
            [textLabel release];
        }
        else
        {}
    }
    return self;
}

#pragma mark -
#pragma mark Set indexPath
- (void)setIndexPath:(NSIndexPath *)indexPath
{
    if([_identifier isEqualToString:REUSEIDENTIFIER_0])
    {
        UIImageView *imageView = (UIImageView *)[self.contentView viewWithTag:IMAGEVIEW_TAG];
        UILabel     *textLabel = (UILabel *)[self.contentView viewWithTag:TEXTLABEL_TAG];
        
        switch (indexPath.row)
        {
            case 0:
            {
                [imageView setImage:[UIImage imageNamed:@"cooperation_icon.png"]];
                [textLabel setText:NSLocalizedString(@"喜欢就打分鼓励一下吧^_^", nil)];
            }
                break;
            case 1:
            {
                [imageView setImage:[UIImage imageNamed:@"feedback_icon.png"]];
                [textLabel setText:NSLocalizedString(@"意见&建议", nil)];
            }
                break;
            default:
                break;
        }
    }
    else if([_identifier isEqualToString:REUSEIDENTIFIER_1])
    {
        UIImageView *imageView = (UIImageView *)[self.contentView viewWithTag:SECTION_2_IMAGEVIEW_TAG];
        UILabel     *textLabel = (UILabel *)[self.contentView viewWithTag:SECTION_2_TEXTLABEL_TAG];
        
        switch (indexPath.row) {
            case 0:
            {
                [imageView setImage:[UIImage imageNamed:@"festivalsms_icon.png"]];
                [textLabel setText:@"短信祝福"];
            }
                break;
            case 1:
            {
                [imageView setImage:[UIImage imageNamed:@"driver_icon.png"]];
                [textLabel setText:@"模拟驾照考试"];
            }
                break;
            case 2:
            {
                [imageView setImage:[UIImage imageNamed:@"audiobooks_icon.png"]];
                [textLabel setText:@"宝宝乖乖睡觉"];
            }
                break;
            case 3:
            {
                [imageView setImage:[UIImage imageNamed:@"tuanyouworld_icon.png"]];
                [textLabel setText:@"团游世界"];
            }
                break;
            default:
                break;
        }
    }
}

- (void)dealloc
{
    [_indexPath release];
    
    [super dealloc];
}

@end
